/////-----开票管理页面   公共 操作  ----------


import { accAdd, accSub, conversionElement, cloneObject } from '@/utils/util'
import * as Utils from '@/utils/util'
import {
  getEntSvConf, getEntQuarterAmount, getEntMoneyInfo, getSendList,
  queryTaxPayOrder, getInvcCancleCheck, checkLimit, invoiceSettlement,
  getNotFinishedTicket, checkBatteryLimit
} from '@api/invoiceAdminister'
import ModalCurrency from '@views/invoice/common/modalCurrency.vue'

const newInvoiceCommon = {
  components: {
    ModalCurrency
  },
  data(){
    return{
      //年季月开票金额与限制金额
      amountColumn: {
        yearLimit: 470000000,  //企业年度封顶金额470万元
        ladderLimit: 30000000,  //跨阶梯封顶金额30万元（季度）
        yearMoney: 0,  //年度开票金额
        quarterMoney: 0,  //当季开票金额
        inSeasonLimit: 0,  //当季提醒限额--双定模式
        quarterLimit: 0, //季度最大开票限额
        monthMoney: 0,  //当月开票金额
        monthLimit: 0, //当月最大开票限额(服务模式)
        digitalMonthLimit: 0, //数电月度最大限额
        yearTotalMoney: 0,  //年度剩余开票金额
        quarterTotalMoney: 0,  //季度剩余开票金额
        monthTotalMoney: 0,  //月度剩余开票金额
        digitalRemaining: 0, //数电剩余额度
      },
      digitalInfo:{
        approvalMethod: null, ////核定方式 1-查账征收 2-核定征收-双定 3-核定征收-征收率 4-核定征收-应纳税所得率
        bePaidStatus: false,  //true-有待支付的订单
        pageSource: 3,  //3-单笔结算  4-批量结算
        moneyTotal: 0,  //本次结算的发票金额总和
        limitStatus: false,  //企业是否超限额（超征收，数电，服务模式，470万）
      },
      //提示信息
      undoConfig:{
        width: '500px',  //modal宽度
        visible: false,    //modal展示状态
        modalTitle: '',
        title: '',     //标题
        subTitle: '撤销并删除发票信息后，已填写的内容将不会被保存，您确定撤销并删除吗？',     //副标题
        content: '',  //内容
        okText: '确定撤销',    //确定文字
        okType: 'danger',    //确定类型
        cancleText: '暂不撤销',    //取消文字
        cancleType: 'default',    //取消类型
        source: 1,    //来源  ''发送成功  1撤销并删除 2邀请验证 3确认寄送 4删除草稿 6订单创建成功
      },
    }
  },
  methods: {
    //父组件返回成功调用(删除草稿,撤销并删除,邀请验证,发送成功,订单创建成功)
    fatherMethod(config){
      //确定撤销
      this.$nextTick(()=>{
        this.undoConfig.visible = false;
      })

      //source来源   ''发送成功  1撤销并删除 2邀请验证 3确认寄送 4删除草稿 6订单创建成功
      if (config.source == 1){
        // 先删除撤销
        //再判断是否影响其他订单 shorFlag 0-否 1-是
        //不影响删除成功，影响请求发票领用接口
        let params = {};
        params.batchList = this.deleteArr;
        getInvcCancleCheck(params).then(res => {
          if (res.success) {
            let data = res.result;
            if (data){
              data.blList.length > 0 ? this.ticketMargin = res.result.blList[0] : '';
              //进入发票领用  shorFlag 0-否 1-是
              data.shorFlag == 1 ? this.undeleteInfo.isCollecteShow = true : this.undeleteOperate();
            }
          }else{
            this.$message.warning(res.message);
          }
        })
      }else if (config.source == 4){
        this.undeleteOperate();
      }else if (config.source == 6){
        //立即支付操作  支付id---config.ext
        let arr = [];
        arr.push(config.ext);
        this.paymentInvoice(arr);
      }else if (config.source == 7){
        //跳转收银台
        this.$router.push({
          path: '/myAccount/accountManage',
          po: 'paymentInvoice'
        });
      }
    },
    //开票结算生成订单id
    getPaymentId(config){
      let params = {};
      params.taxIds = config.payIdList;
      invoiceSettlement(params).then(res => {
        if (res.success) {
          if (res.result){
            let data = cloneObject(res.result.entChargeInfoVOS[0]);
            if(!config.ladder){
              this.$nextTick(()=>{
                this.balanceConfig.visible = false;
              })
            }else{
              this.$nextTick(()=>{
                this.batchConfig.visible = false;
              })
            }

            //订单id   data.payOrder
            this.$nextTick(()=>{
              this.undoConfig = {
                width: '450px',  //modal宽度
                visible: true,    //modal展示状态
                modalTitle: '',
                title: '',     //标题
                subTitle: '订单创建成功！',   //副标题
                content: '',  //内容
                okText: '立即支付',    //确定文字
                okType: 'primary',    //确定类型
                cancleText: '结算其他订单',    //取消文字
                cancleType: 'default',    //取消类型
                source: 6,    //来源
                ext: data.payOrder,     //拓展参数
                cancleRoute: '/invoice/invoiceQueryNew?pagetab=9',     //跳转路由
              }
            })
          }
        }else{
          //判断订单状态弹层
          let code = res.code.toString();  //转字符串

          //作废失败-原订单部分支付单在途/已支付
          if (code.includes('30165')){
            if(!config.ladder){
              this.$nextTick(()=>{
                this.balanceConfig.visible = false;
              })
            }else{
              this.$nextTick(()=>{
                this.batchConfig.visible = false;
              })
            }
            this.$nextTick(()=>{
              this.undoConfig = {
                width: '450px',  //modal宽度
                visible: true,    //modal展示状态
                modalTitle: '',
                title: '',     //标题
                subTitle: '',   //副标题
                content: '订单创建失败!\n' + '原订单正在支付中，请完成原订单支付后再提交新订单',  //内容
                okText: '支付原订单',    //确定文字
                okType: 'primary',    //确定类型
                cancleText: '关闭',    //取消文字
                cancleType: 'primary',    //取消类型
                source: 7,    //来源
                cancleRoute: '/invoice/invoiceQueryNew',     //跳转路由
              }
            })
          }
          //作废失败-原订单全部支付完成
          else if(code.includes('30166') || code.includes('30167')){
            if(!config.ladder){
              this.$nextTick(()=>{
                this.balanceConfig.visible = false;
              })
            }else{
              this.$nextTick(()=>{
                this.batchConfig.visible = false;
              })
            }
            this.$nextTick(()=>{
              this.undoConfig = {
                width: '450px',  //modal宽度
                visible: true,    //modal展示状态
                modalTitle: '',
                title: '',     //标题
                subTitle: '',   //副标题
                content: '订单创建失败!原订单可能已支付，请重新选择要结算的订单!',  //内容
                okText: '',    //确定文字
                okType: '',    //确定类型
                cancleText: '返回发票列表',    //取消文字
                cancleType: 'primary',    //取消类型
                source: 8,    //来源
                cancleRoute: '/invoice/invoiceQueryNew',     //跳转路由
              }
            })
          }
          else{
            this.$message.warning(res.message);
          }
        }
      })
    },
    //-------------------------（金额获取与比对超额逻辑）  start ↓------------------
    //调取比对有无进行中的票并且数电额度是否一致
    async ongoingTicketsDigitalCreditLimit(){
      //获取企业是否有“开票中”或“开票失败”状态的发票
      const queryNotFinishedTicket = await getNotFinishedTicket(this.entId);
      let aFunStatus = this.queryNotFinishedTicketFun(queryNotFinishedTicket);
      //检查数电额度是否一致
      // const checkBatteryToLimit = await checkBatteryLimit(this.entId);
      // let bFunStatus = this.checkBatteryToLimitFun(checkBatteryToLimit);

      if (aFunStatus){
        //调用获取费用和执行金额判断超额
        this.modifyAsynchronous();
      }else {
        //提示存在未完成的开票，不可继续开票
        this.$nextTick(()=>{
          this.undoConfig = {
            width: '500px',  //modal宽度
            visible: true,    //modal展示状态
            modalTitle: '',
            title: '',     //标题
            subTitle: '',     //副标题
            content: '您有尚未完成的开票任务，请优先完成“开票中”及“开票失败”状态的任务处理！',  //内容
            okText: '关闭',    //确定文字
            okType: 'primary',    //确定类型
            cancleText: '',    //取消文字
            cancleType: '',    //取消类型
            source: 9,    //来源
          }
        })
      }


      // if(aFunStatus && bFunStatus){
      //   //调用获取费用和执行金额判断超额
      //   this.modifyAsynchronous();
      // }else{
      //   if(!aFunStatus && bFunStatus){
      //     //提示存在未完成的开票，不可继续开票
      //     this.$nextTick(()=>{
      //       this.undoConfig = {
      //         width: '500px',  //modal宽度
      //         visible: true,    //modal展示状态
      //         modalTitle: '',
      //         title: '',     //标题
      //         subTitle: '',     //副标题
      //         content: '您有尚未完成的开票任务，请优先完成“开票中”及“开票失败”状态的任务处理！',  //内容
      //         okText: '关闭',    //确定文字
      //         okType: 'primary',    //确定类型
      //         cancleText: '',    //取消文字
      //         cancleType: '',    //取消类型
      //         source: 9,    //来源
      //       }
      //     })
      //   }else {
      //     //提示数电额度是否一致
      //     this.$nextTick(()=>{
      //       this.promptConfig = {
      //         width: '650px',
      //         visible: true,    //modal展示状态
      //         content: '企业账户中存在未知发票数据，暂不支持提交结算，请联系客服!',
      //         okText: '关闭',    //确定文字
      //         okType: 'primary',    //确定类型
      //         cancleText: '',    //取消文字
      //         cancleType: '',    //取消类型
      //         expandText: '',    //拓展文字
      //         big: false,    //按钮
      //         source: '5',    //来源  5-数电已开金额与税务局不一致提示
      //         category: 'sd',    //来源  5-数电已开金额与税务局不一致提示
      //       };
      //     })
      //   }
      // }

    },
    //修改异步为同步执行接口
    async modifyAsynchronous(){
      const getEntTaxPayOrder = await queryTaxPayOrder(this.entId);
      this.getEntTaxPayOrderFun(getEntTaxPayOrder);    //获取企业有无待支付的订单

      const getMoneyInfo = await getEntMoneyInfo(this.entId);
      this.getMoneyInfoFun(getMoneyInfo);    //获取开票金额

      const getEntSvConfInfo = await getEntSvConf(this.entId)
      this.getMonthLimitFun(getEntSvConfInfo);    //获取当前企业服务模式下的月度最大限额

      const getEntQuarterAmountInfo = await getEntQuarterAmount(this.entId);
      this.getQuarterAmountFun(getEntQuarterAmountInfo);    //获取当季提醒限额

      const getSendListInfo = await getSendList(this.entId);
      this.getPartyListFun(getSendListInfo);    //获取数电最大限额和可开额度

      if (!this.payStatus){
        //比对该企业总和是否超限额
        this.limitTotal();
      }
    },
    //比对该企业总和是否超限额
    limitTotal(){
      let total; //本次开票金额
      //有待支付的订单
      if (this.digitalInfo.bePaidStatus){
        let payTotal = this.toBePaidList.reduce((sum, item) => { return sum + item.amount }, 0);
        total = accAdd(this.digitalInfo.moneyTotal,payTotal);
      }else{
        total = this.digitalInfo.moneyTotal;
      }

      //已开金额 + 预开金额  是否超过   剩余金额
      let totalMonth = accAdd(total,this.amountColumn.monthMoney);   //该月总用额度
      let totalQuarter = accAdd(total,this.amountColumn.quarterMoney);   //该季度总用额度
      let totalYear = accAdd(total,this.amountColumn.yearMoney);   //该年总用额度

      //计算可结算额度
      let totalNewQuarter;
      //判断核定方式
      this.digitalInfo.approvalMethod == 2  ? totalNewQuarter = this.amountColumn.monthMoney : totalNewQuarter = this.amountColumn.quarterMoney;

      //季度剩余额度 = 季度最大开票限额 - 已开金额 （根据征收方式   双定-月度已开金额  征收率-季度已开金额）
      this.amountColumn.quarterTotalMoney = accSub(this.amountColumn.quarterLimit,totalNewQuarter);

      // console.log('已开金额',totalNewQuarter)
      // console.log('季度最大开票限额',this.amountColumn.quarterLimit)
      // console.log('季度剩余额度',this.amountColumn.quarterTotalMoney)

      //月度剩余额度 = 当月最大开票限额 - 当月已开金额
      this.amountColumn.monthTotalMoney = accSub(this.amountColumn.monthLimit,this.amountColumn.monthMoney);

      this.promptColumn.totalYear = conversionElement(totalYear);  //年度累计开票金额（含本次）
      this.promptColumn.totalQuarter = conversionElement(totalQuarter);  //季度累计开票金额（含本次）
      this.promptColumn.totalMonth = conversionElement(totalMonth);  //月度累计开票金额（含本次）
      this.promptColumn.monthLimit = conversionElement(this.amountColumn.monthLimit);  //服务模式月限额
      this.promptColumn.quarterLimit = conversionElement(this.amountColumn.quarterLimit);  //季度最大开票限额
      this.promptColumn.digitalMonthLimit = conversionElement(this.amountColumn.digitalMonthLimit);  //数电月限额
      this.promptColumn.digitalRemaining = conversionElement(this.amountColumn.digitalRemaining);  //数电剩余额度

      checkLimit(this.entId,total).then(res => {
        if (res.success) {
          // this.digitalInfo.limitStatus = false;
          //判断企业开票总和是否跨阶梯
          this.crossingStairs(total);
        }else{
          //判断展示对应超额弹层
          let code = res.code;
          // console.log('比对超限额',res.message,code)
          //开票金额超470万
          if(code == -210101311){
            //判断是否有待支付订单
            if (this.digitalInfo.bePaidStatus){
              this.$nextTick(()=>{
                this.overLimitConfig = {
                  width: '750px',
                  visible: true,    //modal展示状态
                  category: 'cnd',    //类别
                  source: 4,
                  pendingOrders: 1, //1-有待支付订单  2-无待支付订单
                  mark: this.digitalInfo.mark,
                  settlableLimit: this.amountColumn.yearTotalMoney,  //可结算额度(年度剩余额度)
                };
              })
            }else{
              if (this.digitalInfo.pageSource == 3){
                this.$nextTick(()=>{
                  this.promptConfig = {
                    width: '650px',
                    visible: true,    //modal展示状态
                    okText: '',    //确定文字
                    okType: '',    //确定类型
                    cancleText: '关闭',    //取消文字
                    cancleType: 'primary',    //取消类型
                    expandText: '',    //拓展文字
                    source: 3,
                    category: 'cnd',    //类别
                  };
                  this.promptConfig.content =
                    '结算失败！\n' +
                    '您的开票金额累计' +
                    this.promptColumn.totalYear +
                    '元（含本次），已超过470万/年！'
                })
              }else{
                this.$nextTick(()=>{
                  this.overLimitConfig = {
                    width: '750px',
                    visible: true,    //modal展示状态
                    category: 'cnd',    //类别
                    source: 4,
                    pendingOrders: 2,  //1-有待支付订单  2-无待支付订单
                    mark: this.digitalInfo.mark,
                    settlableLimit: this.amountColumn.yearTotalMoney,  //可结算额度(年度剩余额度)
                  };
                })
              }
            }
          }
          //开票金额超征收限额
          else if (code == -210101312){
            //判断是否有待支付订单
            if (this.digitalInfo.bePaidStatus) {
              this.$nextTick(()=>{
                this.overLimitConfig = {
                  width: '750px',
                  visible: true,    //modal展示状态
                  category: 'czs',    //类别
                  source: 4,
                  pendingOrders: 1, //1-有待支付订单  2-无待支付订单
                  mark: this.digitalInfo.mark,
                  settlableLimit: this.amountColumn.quarterTotalMoney,  //可结算额度(季度剩余额度)
                };
              })
            }else {
              //无待支付订单 && 区分是否单笔结算还是批量结算
              if (this.digitalInfo.pageSource == 3){
                this.$nextTick(()=>{
                  this.promptConfig = {
                    width: '650px',
                    visible: true,    //modal展示状态
                    okText: '',    //确定文字
                    okType: '',    //确定类型
                    cancleText: '关闭',    //取消文字
                    cancleType: 'primary',    //取消类型
                    expandText: '',    //拓展文字
                    source: 3,
                    category: 'czs',    //类别
                  };
                  this.promptConfig.content =
                    '结算失败！\n' +
                    '您本次开票金额累计' +
                    this.promptColumn.totalQuarter +
                    '元（含本次），已超过您适用的税收政策：' +
                    this.promptColumn.quarterLimit +
                    '元，本月内不支持新开票！'
                })
              }else{
                this.$nextTick(()=>{
                  this.overLimitConfig = {
                    width: '750px',
                    visible: true,    //modal展示状态
                    category: 'czs',    //类别
                    source: 4,
                    pendingOrders: 2, //1-有待支付订单  2-无待支付订单
                    mark: this.digitalInfo.mark,
                    settlableLimit: this.amountColumn.quarterTotalMoney,  //可结算额度(季度剩余额度)
                  };
                })
              }
            }
          }
          //开票金额超服务模式限额
          else if (code == -210101313){
            //判断是否有待支付订单
            if (this.digitalInfo.bePaidStatus) {
              this.$nextTick(()=>{
                this.overLimitConfig = {
                  width: '750px',
                  visible: true,    //modal展示状态
                  category: 'cfwms',    //类别
                  source: 4,
                  pendingOrders: 1, //1-有待支付订单  2-无待支付订单
                  mark: this.digitalInfo.mark,
                  settlableLimit: this.amountColumn.monthTotalMoney,  //可结算额度(月度剩余额度)
                };
              })
            }else {
              if (this.digitalInfo.pageSource == 3){
                this.$nextTick(()=>{
                  this.promptConfig = {
                    width: '650px',
                    visible: true,    //modal展示状态
                    okText: '',    //确定文字
                    okType: '',    //确定类型
                    cancleText: '关闭',    //取消文字
                    cancleType: 'primary',    //取消类型
                    expandText: '',    //拓展文字
                    source: 3,
                    category: 'cfwms',    //类别
                  };
                  this.promptConfig.content =
                    '结算失败！\n' +
                    '您本次开票金额累计' +
                    this.promptColumn.totalMonth +
                    '元（含本次），已超过当前服务模式月限额：' +
                    this.promptColumn.monthLimit +
                    '元，本月内不支持新开票！\n' +
                    '您可以在次月提交结算！'
                })
              }else{
                this.$nextTick(()=>{
                  this.overLimitConfig = {
                    width: '750px',
                    visible: true,    //modal展示状态
                    category: 'cfwms',    //类别
                    source: 4,
                    pendingOrders: 2, //1-有待支付订单  2-无待支付订单
                    mark: this.digitalInfo.mark,
                    settlableLimit: this.amountColumn.monthTotalMoney,  //可结算额度(月度剩余额度)
                  };
                })
              }
            }
          }
          //开票金额超数电月限额
          else if (code == -210101314){
            //判断是否有待支付订单
            if (this.digitalInfo.bePaidStatus) {
              this.$nextTick(()=>{
                this.overLimitConfig = {
                  width: '750px',
                  visible: true,    //modal展示状态
                  category: 'sd',    //类别
                  source: 4,
                  pendingOrders: 1, //1-有待支付订单  2-无待支付订单
                  mark: this.digitalInfo.mark,
                  settlableLimit: this.amountColumn.digitalRemaining,  //可结算额度（数电剩余额度）
                };
              })
            }else {
              if (this.digitalInfo.pageSource == 3){
                this.$nextTick(()=>{
                  this.promptConfig = {
                    width: '650px',
                    visible: true,    //modal展示状态
                    okText: '',    //确定文字
                    okType: '',    //确定类型
                    cancleText: '关闭',    //取消文字
                    cancleType: 'primary',    //取消类型
                    expandText: '',    //拓展文字
                    source: 3,    //来源  3-单笔结算  4-批量结算
                    category: 'sd',    //类别
                  };
                  this.promptConfig.content =
                    '结算失败！\n' +
                    '您本次开票金额累计' +
                    this.promptColumn.totalMonth +
                    '元（含本次），已超过您的月核定额度：' +
                    this.promptColumn.digitalMonthLimit +
                    '元，本月内不支持新开票！\n' +
                    '请联系客服，及时修改限额后再结算，或次月提交结算！'
                })
              }else{
                this.$nextTick(()=>{
                  this.overLimitConfig = {
                    width: '750px',
                    visible: true,    //modal展示状态
                    category: 'sd',    //类别
                    source: 4,
                    pendingOrders: 2, //1-有待支付订单  2-无待支付订单
                    mark: this.digitalInfo.mark,
                    settlableLimit: this.amountColumn.digitalRemaining,  //可结算额度（数电剩余额度）
                  };
                })
              }
            }
          }
          else {
            this.$message.warning(res.message);
          }
        }
      })
    },
    //判断企业开票总和是否跨阶梯
    crossingStairs(num){
      let totalQuarter = accAdd(num,this.amountColumn.quarterMoney);   //该季度总用额度

      // console.log('本次开票金额',num)
      // console.log('季度限额',this.amountColumn.quarterLimit)
      // console.log('季度已开金额',this.amountColumn.quarterMoney)
      // console.log('该季度总用额度',totalQuarter)
      // console.log('阶梯限额',this.amountColumn.ladderLimit)

      //跨阶梯   季度已开金额 <= 30万 && 季度已开金额+本次开票金额 >30万
      if (this.amountColumn.quarterMoney <= this.amountColumn.ladderLimit && totalQuarter > this.amountColumn.ladderLimit){

        //判断是否有待支付订单
        if (this.digitalInfo.bePaidStatus) {
          this.$nextTick(()=> {
            this.bePaidConfig = {
              width: '800px',
              visible: true,    //modal展示状态
              ladderStatus: 2, //1-未跨阶梯  2-跨阶梯
              pendingOrders: 1, //1-有待支付订单  2-无待支付订单
              mark: this.digitalInfo.mark,
              source: this.digitalInfo.pageSource, //3-单笔结算  4-批量结算
            };
          })
        }else {
          this.$nextTick(()=> {
            this.batchConfig = {
              width: '850px',
              visible: true,    //modal展示状态
              ladderStatus: 2, //1-未跨阶梯  2-跨阶梯
              pendingOrders: 2, //1-有待支付订单  2-无待支付订单
              mark: this.digitalInfo.mark,
              source: this.digitalInfo.pageSource, //3-单笔结算  4-批量结算
            };
          })
        }
      }else{
        //未跨阶梯
        //判断是否有待支付订单
        if (this.digitalInfo.bePaidStatus) {
          this.$nextTick(()=> {
            this.bePaidConfig = {
              width: '800px',
              visible: true,    //modal展示状态
              ladderStatus: 1, //1-未跨阶梯  2-跨阶梯
              pendingOrders: 1, //1-有待支付订单  2-无待支付订单
              mark: this.digitalInfo.mark,
              source: this.digitalInfo.pageSource, //3-单笔结算  4-批量结算
            };
          })
        }else {
          let width;
          if (this.digitalInfo.pageSource == 3){
            width = '450px';
          }else {
            width = '800px';
          }
          //setTimeout  解决调用接口与弹层展示同时执行
          setTimeout(()=>{
            this.$nextTick(()=> {
              this.balanceConfig = {
                width: width,
                visible: true,    //modal展示状态
                ladderStatus: 1, //1-未跨阶梯  2-跨阶梯
                pendingOrders: 2, //1-有待支付订单  2-无待支付订单
                mark: this.digitalInfo.mark,
                source: this.digitalInfo.pageSource, //3-单笔结算  4-批量结算
              };
            })
          },1000);
        }
      }
    },
    //获取企业是否有“开票中”或“开票失败”状态的发票
    queryNotFinishedTicketFun(res){
      if (res.success) {
        if (res.result){
          //true 代表存在未完成的开票，不可继续开票
          return false;
        }else {
          return true;
        }
      }else{
        this.$message.warning(res.message);
      }
    },
    //检查数电额度是否一致
    checkBatteryToLimitFun(res){
      if (res.success) {
        if (res.result){
          // true 没问题
          return true;
        }else {
          return false;
        }
      }else{
        this.$message.warning(res.message);
      }
    },
    //获取企业有无待支付的订单
    getEntTaxPayOrderFun(res) {
      if (res.success) {
        if (res.result){
          let data = res.result || [];
          if (data.length > 0){
            //有待支付的订单
            this.digitalInfo.bePaidStatus = true;
            //先清空数组 再赋值数据
            let newData = cloneObject(data);
            newData.forEach(obj => {
              obj.checkShow = true;
              obj.pendingOrders = 1;
            });
            this.toBePaidList = newData;

            //待支付的撤销
            if (this.payStatus){
              newData.forEach(obj => {
                obj.checkShow = true;
              });
              this.payCheckList = newData;
              this.$nextTick(()=> {
                this.payRevokeConfig.visible = true;
              })
            }

          }else{
            //无待支付的订单
            this.digitalInfo.bePaidStatus = false;
          }
        }
      }else{
        this.$message.warning(res.message);
      }
    },
    //获取开票金额
    getMoneyInfoFun(res){
      if (res.success) {
        let data = res.result;
        if (data){
          let dataNew = cloneObject(data);
          this.amountColumn.quarterMoney = dataNew.quarterMoney;  //当季开票金额
          this.amountColumn.yearTotalMoney = dataNew.yearBalanceMoney; //年度剩余开票金额
          this.amountColumn.yearMoney = dataNew.yearMoney;  //年度开票金额
          this.amountColumn.quarterLimit = dataNew.quarterMoneyLimit;  //季度最大开票限额
          this.amountColumn.monthMoney = dataNew.monthMoney;  //当月开票金额
        }
      }else{
        this.$message.warning(res.message);
      }
    },
    //获取当前企业服务模式下的月度最大限额
    getMonthLimitFun(res){
      if (res.success) {
        if (res.result){
          let data = res.result.invoiceMax || 0;
          this.amountColumn.monthLimit = data;
        }
      }else{
        this.$message.warning(res.message);
      }
    },
    //获取当季提醒限额
    getQuarterAmountFun(res){
      if (res.success){
        this.amountColumn.inSeasonLimit = res.result;
      }else{
        this.$message.warning(res.message);
      }
    },
    //获取数电最大限额和可开额度
    getPartyListFun(res){
      if (res.success) {
        if (res.result){
          let data = res.result;
          //获取数电相关数据
          if (data.length > 0 && data[0].entDetail){
            let juridicalDate = data[0].entDetail;
            this.digitalInfo.ticketType = juridicalDate.ticketType;  //开票类型 1-传统票 2-数电票 3-混合票
            this.digitalInfo.approvalMethod = juridicalDate.taxMode;  //核定方式 1-查账征收 2-核定征收-双定 3-核定征收-征收率 4-核定征收-应纳税所得率
            this.amountColumn.digitalMonthLimit = juridicalDate.maxSdAmount;  //数电月度最大限额
            this.amountColumn.digitalRemaining = juridicalDate.lastSdAmount;  //数电月度剩余限额
          }
        }
      }else{
        this.$message.warning(res.message);
      }
    },
  }
}

export  default  newInvoiceCommon
